package tests.user;

import tester.*;

/**
 * Copyright 2007, 2008 Viera K. Proulx
 * This program is distributed under the terms of the 
 * GNU Lesser General Public License (LGPL)
 */

/**
 * A class to represent a nonempty list of objects 
 * of the type <code>T</code>
 * 
 * @author Viera K. Proulx
 * @since 30 May 2007
 */
public class ConsList<T extends ISame<T>> implements AList<T>{

  /** The first object in this list */
  public T first;
  /** The rest of this list */
  public AList<T> rest;

  public ConsList(T first, AList<T> rest){
    this.first=first;
    this.rest=rest;
  }

  /**
   * Does this list contain the given object?
   * 
   * @param that the given object
   * @return true if the list contains the given object
   */  
  public boolean contains(T that){ 
    if (this.first.same(that))
      return true;
    else 
      return this.rest.contains(that); 
  } 
} 
